local M = {}

local log = require("log"):new("svc_test_cmd")
local pb = require("protobuf")
local mongotest = require("test/mongodb_test")
local mongo_rs_test = require("test/mongodb_replica_set_test")

-- Return LoginResponse.
local function testcmd(ctx, request)
	if request.cmd=="mongodb_test" then
		return mongotest.test(ctx, request)
	elseif request.cmd=="mongo_rs" then
		mongo_rs_test.test(ctx, request)
	end	
	return {cmd = request.cmd, result = "OK"}
end  -- testcmd()

function M.TestCmd(ctx, content)
	local req = pb.decode("svr.TestCmdRequest", content)
	local resp = testcmd(ctx, req)
	assert("table" == type(resp))
	c_rpc.reply_to(ctx, pb.encode("svr.TestCmdResponse", resp))
end  -- TestCmd()

require("rpc_request_handler").register_service("svr.TestCmd", M)
return M 
